package com.trans.file;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

public class ReadFile {
	public String getFile() {
		String str = "";
		//		File directory = new File("");//设定为当前文件夹
		//		System.out.println(directory.getAbsolutePath());//获取绝对路径
		//		System.out.println(directory.getPath()); //获得new File()时设定的路径
		//		System.out.println(System.getProperties());
		try {
			File file = new File("D:\\TempFiles\\IntellijIdea\\Pisum\\FastJson\\src\\main\\java\\com\\trans\\file\\String.txt");

			FileInputStream in = new FileInputStream(file);

			// size  为字串的长度 ，这里一次性读完

			int size = in.available();

			byte[] buffer = new byte[size];

			in.read(buffer);

			in.close();

			str = new String(buffer, "utf-8");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		return str;

	}

}
